/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Progra1;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author manuel
 */
public class servletCaso6 extends HttpServlet {
  private static final long serialVersionUID = 1L;
 
    public servletCaso6() {
            super();
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        try {
            Caso6BD manejoBD = new Caso6BD();
            manejoBD.conectarBD();
            int page = 1;
            int caso=1;
            int recordsPerPage = 50;
            if (request.getParameter("page") != null) {
                page = Integer.parseInt(request.getParameter("page"));
                //caso= Integer.parseInt(request.getParameter("caso"));
            }
             ArrayList<Caso4Poliza> listaClientes;
            if(caso==1){
                listaClientes = manejoBD.Caso6ConsultaTotal((page - 1) * recordsPerPage,
                    recordsPerPage);
                request.setAttribute("listaClientes", listaClientes);
            }else if(caso==2){
                listaClientes= manejoBD.Caso6ConsultaTotal();
                request.setAttribute("listaClientes", listaClientes);
            }
            
            int numeroPaginas = (int) Math.ceil(1000 * 1.0 / recordsPerPage);
            
            request.setAttribute("numeroPaginas", numeroPaginas);
            request.setAttribute("paginaActual", page);
            request.setAttribute("casoActual", caso);
            request.setAttribute("duracion", manejoBD.getDuracion());
            RequestDispatcher view = request.getRequestDispatcher("Caso6.jsp");
            view.forward(request, response);

        } catch (Throwable exc) {
            System.out.println(exc);
        }
    }
}
